#include <bits/stdc++.h>

using namespace std;
struct tree
{
    int id,droped;
    tree(int _id,int _droped)
    {
        this->id=_id;
        this->droped=_droped;
    }
    tree()
    {

    }
};

int main_62()
{
    int N,mi,T=0,D=0,E=0,cnt=0,op;
    queue<tree> is_drop;
    scanf("%d",&N);
    for (int j=1;j<=N ;++j )
    {
        scanf("%d%d",&mi,&cnt);
        bool flag=false;
        for (int i=1; i<mi ; ++i )
        {
            scanf("%d",&op);
            if (op<=0)
            {
                cnt+=op;
            }
            else
            {
                if (cnt>op)
                {
                    flag=true;
                }
                cnt=op;
            }
        }
        if (!flag)
        {
            is_drop.push(tree(j,0));
        }else
        {
            ++D;
            is_drop.push(tree(j,1));
        }
        T+=cnt;
    }
    tree ai0,ai1,ai2;
    do
    {
        ai0=is_drop.front(),is_drop.pop();
        ai1=is_drop.front(),is_drop.pop();
        ai2=is_drop.front(),is_drop.pop();
        if (ai0.droped&&ai1.droped&&ai2.droped)
        {
            ++E;
        }
        is_drop.push(ai0);
        is_drop.push(ai1);
        is_drop.push(ai2);
    } while (is_drop.front().id!=1);
    printf("%d %d %d",T,D,E);
    return 0;
}
